pub(crate) fn main(){
    let content = get_content();
    let lines = content.lines();
    let mut arr = ["";150];
    let mut count: usize = 0;
    for (idx,line) in lines.into_iter().enumerate() {
        arr[idx] = line;
        count = idx+1;
    }

    for idx in 0..count {
        for idx2 in idx+1..count {
            let line = arr[idx];
            let line2 = arr[idx2];
            // println!("======line={} line2 = {}",line, line2);
            if !cmp(line, line2){
                let t = arr[idx];
                arr[idx] = arr[idx2];
                arr[idx2] = t;
            }
        }
    }
    println!("排序结果：");
    let ss = 3;
    for idx in 0..count {
        println!("{}", arr[idx]);
    }
}

fn cmp(l1: &str, l2: &str) -> bool {
    let split = l1.split_whitespace();
    let x:Vec<&str> = split.collect();
    let size_str:&str = x[0];

    let split2 = l2.split_whitespace();
    let x2:Vec<&str> = split2.collect();
    let size_str2:&str = x2[0];

    let size1 = real_size(size_str);
    let size2 = real_size(size_str2);
    // println!("cmp==========l1={} l2={} str1={} str2={}  size1={}, size={}",
    //          l1, l2, size_str, size_str2, size1, size2);

    size1 > size2
}

fn real_size(size_str: &str) -> f64 {
    let mut size1:f64 = 0.0;
    if size_str.contains("G") {
        size1 = (size_str[0..size_str.len() - 1]).parse::<f64>().expect("parse failed")
            * 1000f64 * 1000f64 * 1000f64;
    } else if size_str.contains("M") {
        size1 = (size_str.to_string()[0..size_str.len() - 1]).parse::<f64>().expect("parse failed")
            * 1000f64 * 1000f64;
    } else if size_str.contains("K") {
        size1 = (size_str[0..size_str.len() - 1]).parse::<f64>().expect("parse failed")
            * 1000f64;
    } else {
        size1 = (size_str[0..size_str.len()]).parse::<f64>().expect("parse failed")
            * 1.0;
    }
    size1
}

fn get_content() -> String {
    "5.2M    7-Zip
979M    AdobePhotoshopCS6(64bit)Portable
206M    aliwang
42M     Ant-1.10.4
101M    apache-activemq-5.15.5
45M     apache-ant-1.10.10
10M     apache-maven-3.5.0
52M     apache-tomcat-8.5.16
2.1G    AutoCad2013
410M    BaiduNetdisk
6.4M    BitSpirit
632K    blmt
93M     btzhai
11M     CAJ_viewer
192M    calibre
87M     CloudMusic
260M    CodeBlocks
108M    consul
1007M   contra
4.7M    CPU-Z
186M    Dict
4.6M    Dism++ 10.1.1.6
305M    draw.io
22M     DriverGenius
7.4M    EasyBoot
4.6M    EasyCHM
505M    eclipse
112M    eudic
20M     Everything
330M    FFmpeg
16M     Fiddler
46M     filebrowser
28M     FileZilla FTP Client
3.5M    Flash Player Class
576M    FormatFactory
508M    Foxmail
10M     frp_0.27.1
217M    gdb-8.2
6.9M    geek.exe
266M    Git
353M    go
4.3M    HD Tune Pro
33M     huorong
36K     idea-reset
2.0G    IntelliJ IDEA
218M    IntelliJ IDEA 2019.2.4
23M     Internet Download Manager
292M    Java
338M    jdk1.8.0_45
12M     JisuPdf
0       Jprofiler
306M    jprofiler12
1.0K    kpdfconvertersdk.kid
79M     kwifi
41M     LAV Filters
1.0K    local64spl.dll.ini
263M    M3U8-Downloader-win_x64-2.0.6
17M     MathType
308M    MediaCoder
191M    Microsoft VS Code
79M     MiFlash2018-5-28-0
4.0K    Navicat for MySQL
4.0M    nginx-1.14.2
20M     ngrok
59M     nodeJs
16M     Notepad++
2.1G    Office Tool
15M     PanDownload
93M     PotPlayer
2.8M    ProxyCap
3.7M    Putty
957M    PyCharm 2019.2
80M     Python2
0       qq_course
8.2G    Qt
27K     QTier
130M    quanhuahng
97M     quanhuqng
84M     Qv2ray
153M    redis
1.4M    rufus-3.11
83M     SecurtCRT
34M     snipaste
183M    SogouInput
24M     SPlayer
23M     SQLyog
13M     SVN Client
361M    TDM-GCC
94M     Telegram
607M    Thunder
262M    ThunderX
428M    TIM
197M    Tor Browser
103M    TortoiseGit
84M     Trojan-Qt5-Windows-1.1.5
151M    TXEDU
59M     Typeeasy
194M    Typora
1.1M    Universal-user-installer
3.6M    uTorrent
41M     VirtualBox
0       VisualStudio
169M    VLC
987M    VM16Pro
257M    VS Code
848M    WeChat
84M     WinSCP
391M    WPS Office
81M     wxb
37M     xiangrikui
48M     Xshell6Portable
8.1M    YiLu
210M    YoudaoNote
0       YoudaoNoteAddin
42M     ZeroNet-win-dist-win64
125M    zookeeper-3.4.11
211M    翻墙
2.2M    函数绘图器
26M     即时通
391M    模拟fc游戏全集
1.9M    模拟器GBA
738K    模拟器NES
825K    新建文件夹
203M    迅雷X 10.1.28.676
160K    映射工具
192M    植物".to_string()
}